<!DOCTYPE html>
<html xmlns:v-on="http://www.w3.org/1999/xhtml">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 登录</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>if (window.top !== window.self) {
        window.top.location = window.location;
    }</script>
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown" id="app">
    <div>
        <h3>虹软测试平台</h3>

        <form class="m-t" role="form" action="index.html" onsubmit="return false;">
            <div class="form-group">
                <input type="text" class="form-control" v-model="username" placeholder="用户名" required="">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" v-model="password" placeholder="密码" required="">
            </div>
            <button type="submit" class="btn btn-primary block full-width m-b" v-on:click="login">登 录</button>
            </p>
        </form>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.7"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>

</body>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            username: '',
            password: ''
        },
        methods: {
            login: function () {
                axios.post('/login', {
                    username: this.username,
                    password: this.password
                }).then(res => {
                    let {code, message, data} = res.data;
                    if (code !== 0) {
                        alert(message)
                    } else {
                        Cookies.set('token', data)
                        window.location.href = 'http://localhost:8080/index.html';
                    }
                })
            }
        }
    });
</script>
</html>
